{extend name="base/base" /}
{block name="style"}
<style type="text/css">

</style>
{/block}
{block name="content"}
  <div class="layui-form-item layui-form-pane">
     <div class="layui-inline">
          <label class="layui-form-label">转账币种</label>
          <div class="layui-input-inline">
              <input type="text" name="coin_name" autocomplete="off" class="layui-input" id='coin_name'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">转账方</label>
          <div class="layui-input-inline">
              <input type="text" name="username" autocomplete="off" class="layui-input" id='username'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">转账方电话</label>
          <div class="layui-input-inline">
              <input type="text" name="phone" autocomplete="off" class="layui-input" id='phone'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">收款方</label>
          <div class="layui-input-inline">
              <input type="text" name="to_name" autocomplete="off" class="layui-input" id='to_name'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">收款方电话</label>
          <div class="layui-input-inline">
              <input type="text" name="to_phone" autocomplete="off" class="layui-input" id='to_phone'>
          </div>
      </div>
       <div class="layui-inline">
          <label class="layui-form-label">转账时间</label>
          <div class="layui-input-inline">
              <input type="text" class="layui-input" name="start_time" id="start_time" placeholder="yyyy-MM-dd">
          </div>
          <div class="layui-form-mid">-</div>
          <div class="layui-input-inline">
              <input type="text" class="layui-input" name="end_time" id="end_time" placeholder="yyyy-MM-dd">
          </div>
      </div>
      <div class="layui-inline">
        <div class="demoTable">
          <button class="layui-btn" data-type="reload">搜索</button>
          <button class="layui-btn" onclick="excel()">导出表</button>
        </div>
      </div>
  <table id="table" lay-filter="table"></table> 
    <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">回复</a>
  </script>
</div>
{/block}
{block name="script"}
<script>
layui.use(['table', 'laydate'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  table.render({
    elem: '#table'
    ,height: 'full-200'
    ,url: '/admin/Transfer/dataList/' //数据接口
    ,limit:20
    ,page: true //开启分页
    ,id:'reload'
    ,cols: [[ //表头
        {field:'wallet_name', title: '转账币种', width: 100}
      ,{field:'phone', title: '转账方电话', width: 150}
      ,{field:'username', title: '转账方', width: 200}
      ,{field:'amount', title: '转账数量', width: 150}
      ,{field:'fee', title: '转账手续费', width: 150}
      ,{field:'date', title: '转账时间', width: 200}
      ,{field:'to_phone', title: '收款方电话', width: 150}
      ,{field:'to_name', title: '收款方', width: 200}
      ,{field:'amount', title: '收款金额', width: 200}
    ]]
  }); 
    // 搜索
  var $ = layui.$, active = {
        reload: function(){
            table.reload('reload', {
                where: {
                    phone: $('#phone').val(),
                    to_phone: $('#to_phone').val(),
                    username: $('#username').val(),
                    to_name: $('#to_name').val(),
                    coin_name: $('#coin_name').val(),
                    start_time: $('#start_time').val(),
                    end_time: $('#end_time').val()
                }
            });
        }
    };
    $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
  //日期
  laydate.render({
    elem: '#start_time'
  });
  laydate.render({
    elem: '#end_time'
  });    
});
function excel(){
  // var index = layer.msg('正在拼命处理...' , {
  //       icon: 16 ,
  //       shade: 0.6 ,
  //       time: 0 ,
  //     });
  var post_data = {
                    phone: $('#phone').val(),
                    to_phone: $('#to_phone').val(),
                    username: $('#username').val(),
                    to_name: $('#to_name').val(),
                    coin_name: $('#coin_name').val(),
                    start_time: $('#start_time').val(),
                    end_time: $('#end_time').val()
                }
  $.ajax({
    url:"{:url('admin/Transfer/excel')}",
    type:"POST",
    data:post_data,
    success:function(ret){
      //alert(ret);
      location.href='/'+ret;
    }
  }); 
}
</script>
{/block}
